//
//  HomeViewCell.m
//  EastMarket
//
//  Created by 李鹏程 on 16/11/15.
//  Copyright © 2016年 guoguo. All rights reserved.
//

#import "HomeViewCell.h"

@implementation HomeViewCell
- (id)initWithFrame:(CGRect)frame {
    
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = [UIColor clearColor];
        
        CGFloat spacing = 8.0f;
        CGFloat border = 1.0f;
        CGFloat Textheight = 26;
        _iconImg = [[UIImageView alloc] initWithFrame:CGRectMake(spacing, spacing, self.frame.size.width - spacing * 2, self.frame.size.width - spacing * 2)];
        [self.contentView addSubview:_iconImg];
        
        _lblTitle = [[UILabel alloc] initWithFrame:CGRectMake(spacing, _iconImg.frame.origin.y + _iconImg.frame.size.height + spacing, self.frame.size.width - 2 * spacing, Textheight)];
        [_lblTitle setFont:[UIFont systemFontOfSize:12]];
        _lblTitle.textColor = EastMarket_darkBlackFontColor;
        _lblTitle.textAlignment = NSTextAlignmentCenter;
        [self.contentView addSubview:_lblTitle];
        
        _lblPrice = [[UILabel alloc] initWithFrame:CGRectMake(spacing, _lblTitle.frame.origin.y + _lblTitle.frame.size.height + border, self.frame.size.width - 2 * spacing, Textheight)];
        [_lblPrice setFont:[UIFont systemFontOfSize:12]];
        _lblPrice.textColor = EastMarket_MainToneColor;
        [self.contentView addSubview:_lblPrice];
        
        _btnNumReduce = [[UIButton alloc] initWithFrame:CGRectMake((self.frame.size.width - 72) / 2, _lblPrice.frame.origin.y + _lblPrice.frame.size.height + border, Textheight, Textheight)];
        [_btnNumReduce setTitle:@"-" forState:UIControlStateNormal];
        [_btnNumReduce setTitleColor:EastMarket_MainToneColor forState:UIControlStateNormal];
        _btnNumReduce.layer.borderWidth = border;
        _btnNumReduce.layer.borderColor = [EastMarket_hintFontColor CGColor];

        _btnNumReduce.titleLabel.textColor = [UIColor blackColor];
        [self.contentView addSubview:_btnNumReduce];
        
        _lblNum = [[UILabel alloc] initWithFrame:CGRectMake(_btnNumReduce.frame.origin.x + _btnNumReduce.frame.size.width, _btnNumReduce.frame.origin.y, 28, _btnNumReduce.frame.size.height)];
        [_lblNum setFont:[UIFont systemFontOfSize:12]];
        _lblNum.layer.borderColor = [EastMarket_hintFontColor CGColor];
        _lblNum.viewBorder = viewBorderTop | viewBorderBottom;
        _lblNum.textColor = [UIColor blackColor];
        _lblNum.textAlignment = NSTextAlignmentCenter;
        [self.contentView addSubview:_lblNum];
        
        _btnNumAdd = [[UIButton alloc] initWithFrame:CGRectMake(_lblNum.frame.origin.x + _lblNum.frame.size.width, _btnNumReduce.frame.origin.y, _btnNumReduce.frame.size.width, _btnNumReduce.frame.size.height)];
        [_btnNumAdd setTitle:@"+" forState:UIControlStateNormal];
        [_btnNumAdd setTitleColor:EastMarket_MainToneColor forState:UIControlStateNormal];
        _btnNumAdd.layer.borderWidth = border;
        _btnNumAdd.layer.borderColor = [EastMarket_hintFontColor CGColor];
        [self.contentView addSubview:_btnNumAdd];
    }
    return self;
}

/*
- (void)btnNumAddOperateClick {
    
    CGPoint btnPoint=[self convertPoint:_btnNumAdd.center toView:self.superview];
    self.block(btnPoint);
    
    if (self.btnNumAddClick) {
        self.btnNumAddClick();
    }
}
- (void)btnNumReduceOperateClick {
    if (self.btnNumReduceClick) {
        self.btnNumReduceClick();
    }
}
 */
@end
